#include <stdio.h>
struct student{
    int num;
    char name[20];
    char sex;
};

int main() {
    struct student s={1001,"lixiang",'M'};
    struct student sarr[3]={1002,"zj",'M',1003,"fc",'W',1004,"HJ",'W'};
    struct student *p;//定义了一个指针变量
    p=&s;
    printf("%d %s %c\n",(*p).num,(*p).name,(*p).sex);//方式一 不推荐
    printf("%d %s %c\n",p->num,p->name,p->sex);//方式二 ＜（＾－＾）＞
    for (int i = 0; i < 3 ;i++) {
        p=&sarr[i];//p=sarr等价与p=&sarr[0]
        printf("%d %s %c\n",p->num,p->name,p->sex);
    }
    //指针偏移
    printf("******************\n");
    p=sarr;
    for(int i = 0;i<3;i++)
    {
        printf("%d %s %c\n",p->num,p->name,p->sex);
        p=p+1;
    }

    return 0;
}
